<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.js"></script>
    <script>
        function getData() {
            let user = document.querySelector(".user").value
            let psd = document.querySelector(".psd").value
            if (user && psd){
                let params = {
                    email:user,
                    psd:psd
                }
                axios.post("/webDemo/servlet/login", params).then(function (response) {
                    console.log("===axios 获取的数据", response)
                    let result = response.data
                    console.log("===登录接口返回的数据=", result)
                    if (result.code === 200){
                        // 登录成功
                        window.location.href = "/webDemo/sub/home.html"
                    }else {
                        window.location.href = "/webDemo/sub/login.html"
                    }
                }).catch(function (error) {
                    console.log(error);
                })
            }
        }
    </script>
</head>
<body>
<div>
    <label>邮 箱</label><input class="user" name="user" placeholder="请输入邮箱名"/><br/>
    <label>密 码</label><input class="psd" name="psd" type="password" placeholder="请输入密码"/><br/>
    <button onclick="getData()">登录</button>
    <div class="hint"></div>
</div>
</body>
</html>